package com.yulan.Array;

/**
 * 48. 旋转图像
 */
public class LeetCode_48 {
    public void rotate(int[][] matrix) {
        int n = matrix.length;

        /**
         * 转置
         */
        for(int i = 0;i < n; i++){
            for(int j = i;j < n;j++){
                int tmp = matrix[i][j];
                matrix[i][j] = matrix[j][i];
                matrix[j][i] = tmp;
            }
        }
        /**
         * 水平翻转
         */
        for(int i = 0;i < n;i++){
            for(int j = 0;j < n/2;j++){
                int tmp = matrix[i][j];
                matrix[i][j] = matrix[i][n-j-1];
                matrix[i][n-j-1] = tmp;
            }
        }

    }

}
